home *** CD-ROM | disk | FTP | other *** search
- _global.synchroneCLASS = function()
- {
- this.targetInitBytes = 0;
- this.tftStyle = new TextFormat();
- this.tftStyle.align = "center";
- this.tftStyle.color = 16777215;
- this.tftStyle.font = "eurostile";
- this.tftStyle.size = 16;
- this.backLimit = 50;
- this.useShade = true;
- this.useBox = false;
- this.useSubtitle = false;
- };
- _global.synchroneCLASS.prototype.videoPreloader = function()
- {
- var bounds;
- this.target.gotoAndStop(1);
- this.target._visible = false;
- if(!this.useSubtitle)
- {
- trace(this.target.getBytesLoaded());
- if(this.target.getBytesLoaded() != this.targetInitBytes)
- {
- clearInterval(this.videoPreloaderInterval);
- this.target._visible = true;
- this.onDataTarget[this.onDataMethod].apply(this.onDataTarget,this.onDataArguments);
- }
- }
- else if(this.target.getBytesLoaded != this.targetInitBytes && this.target._framesloaded > _global.FPS && this.subParser.getBytesTotal() > 0 && this.subParser.getBytesLoaded() == this.subParser.getBytesTotal())
- {
- clearInterval(this.videoPreloaderInterval);
- this.target._visible = true;
- bounds = this.target.getBounds(this.target);
- if(this.textX == null)
- {
- this.textX = (bounds.xMax - bounds.xMin) / 2 + bounds.xMin;
- }
- if(this.textY == null)
- {
- this.textY = bounds.yMax;
- }
- this.lastFrame = 1;
- this.synchronizeInterval = setInterval(this,"synchronize",1000 / (_global.FPS + 1));
- this.onDataTarget[this.onDataMethod]();
- }
- };
- _global.synchroneCLASS.prototype.synchronize = function()
- {
- var i;
- var subText;
- if(this.lastFrame == this.target._currentframe)
- {
- return undefined;
- }
- this.lastFrame = this.target._currentframe;
- subText = null;
- i = this.target._currentframe;
- while(i > this.target._currentframe - this.backLimit)
- {
- if(this.subObj[i] != null)
- {
- if(this.target._currentframe < this.subObj[i].end)
- {
- subText = this.subObj[i].text;
- }
- break;
- }
- i--;
- }
- if(this.lastSubText != subText)
- {
- this.display(subText);
- }
- this.lastSubText = subText;
- };
- _global.synchroneCLASS.prototype.display = function(str)
- {
- var lineArr;
- var lines;
- var extentHeight;
- var lineExtent;
- if(str == null)
- {
- if(this.tfSubBox instanceof TextField)
- {
- this.tfSubBox.removeTextField();
- }
- if(this.tfSubBoxShadow instanceof TextField)
- {
- this.tfSubBoxShadow.removeTextField();
- }
- if(this.mSubBox instanceof MovieClip)
- {
- this.mSubBox.removeMovieClip(this);
- }
- return undefined;
- }
- if(!(this.tfSubBox instanceof TextField))
- {
- this.target.createTextField("tfSubBox",3,this.textX,0,0,0);
- this.tfSubBox = this.target.tfSubBox;
- this.tfSubBox.selectable = false;
- this.tfSubBox.autoSize = "center";
- this.tfSubBox.html = true;
- this.tfSubBox.embedFonts = true;
- }
- this.tfSubBox.htmlText = str.split("\n").join("<br>");
- this.tfSubBox.setTextFormat(this.tftStyle);
- this.tfSubBox._y = this.textY - this.tfSubBox._height;
- if(this.useShade)
- {
- if(!(this.tfSubBoxShadow instanceof TextField))
- {
- this.target.createTextField("tfSubBoxShadow",2,this.textX + 1,0,0,0);
- this.tfSubBoxShadow = this.target.tfSubBoxShadow;
- this.tfSubBoxShadow.selectable = false;
- this.tfSubBoxShadow.autoSize = "center";
- this.tfSubBoxShadow.html = true;
- this.tfSubBoxShadow.embedFonts = true;
- }
- this.tfSubBoxShadow.htmlText = str.split("\n").join("<br>");
- this.tfSubBoxShadow.setTextFormat(this.tftStyle);
- this.tfSubBoxShadow.textColor = 0;
- this.tfSubBoxShadow._y = this.textY - this.tfSubBoxShadow._height + 1;
- }
- if(this.useBox)
- {
- if(!(this.mSubBox instanceof MovieClip))
- {
- this.mSubBox = this.target.createEmptyMovieClip("mSubBox",1);
- this.mSubBox.beginFill(0,30);
- this.mSubBox.lineTo(100,0);
- this.mSubBox.lineTo(100,100);
- this.mSubBox.lineTo(0,100);
- this.mSubBox.endFill();
- }
- this.mSubBox._x = this.tfSubBox._x;
- this.mSubBox._y = this.tfSubBox._y;
- this.mSubBox._width = this.tfSubBox._width;
- this.mSubBox._height = this.tfSubBox._height;
- }
- };
- _global.synchroneCLASS.prototype.load = function(target, videoFile, subtitleFile, textX, textY)
- {
- if(!this.target instanceof MovieClip)
- {
- return undefined;
- }
- this.target = target;
- this.targetInitBytes = this.target.getBytesTotal();
- if(subtitleFile != null)
- {
- if(parseFloat(textX) != textX.toString() || textX == null)
- {
- delete this.textX;
- }
- else
- {
- this.textX = textX;
- }
- if(parseFloat(textY) != textY.toString() || textY == null)
- {
- delete this.textY;
- }
- else
- {
- this.textY = textY;
- }
- this.subObj = new Object();
- this.lastSubText = null;
- this.useSubtitle = true;
- this.subParser = new _global.subParserCLASS();
- this.subParser.load(subtitleFile,this.subObj);
- }
- else
- {
- this.useSubtitle = false;
- }
- this.videoFile = videoFile;
- this.target.loadMovie(this.videoFile);
- this.videoPreloaderInterval = setInterval(this,"videoPreloader",1000 / (_global.FPS + 1));
- this.videoPreloader();
- };
- _global.synchroneCLASS.prototype.setOnData = function(target, method)
- {
- this.onDataTarget = target;
- this.onDataMethod = method;
- this.onDataArguments = arguments.slice(2);
- };
- _global.synchroneCLASS.prototype.getOnData = function(target, name)
- {
- return this.onDataTarget[this.onDataMethod];
- };
- _global.synchroneCLASS.prototype.setBox = function(state)
- {
- this.box = !state ? false : true;
- };
- _global.synchroneCLASS.prototype.getBox = function()
- {
- return this.box;
- };
- _global.synchroneCLASS.prototype.setShade = function(state)
- {
- this.shade = !state ? false : true;
- };
- _global.synchroneCLASS.prototype.getShade = function()
- {
- return this.shade;
- };
- _global.synchroneCLASS.prototype.unload = function()
- {
- clearInterval(this.synchronizeInterval);
- this.target.unloadMovie();
- this.subParser.unload();
- };
-